widget: Set state flags for direction
authorBenjamin Otte <otte@redhat.com>
Tue, 18 Dec 2012 16:31:10 +0000 (17:31 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 18 Dec 2012 17:25:42 +0000 (18:25 +0100)
gtk/gtkwidget.c

index 13f7b7953dc0f3fe1a44f18a975beecb4e82949f..88f4148fe6007b6fdd53f68cc82f62790d007c09 100644 (file)
@@ -3675,6 +3675,7 @@ gtk_widget_init (GtkWidget *widget)
   priv->double_buffered = TRUE;
   priv->redraw_on_alloc = TRUE;
   priv->alloc_needed = TRUE;
+  priv->state_flags = GTK_STATE_FLAG_DIR_LTR;
 
   /* this will be set to TRUE if the widget gets a child or if the
    * expand flag is set on the widget, but until one of those happen
@@ -10134,11 +10135,35 @@ static void
 gtk_widget_emit_direction_changed (GtkWidget        *widget,
                                    GtkTextDirection  old_dir)
 {
+  GtkTextDirection direction;
+  GtkStateFlags state;
+
   gtk_widget_update_pango_context (widget);
 
+  direction = gtk_widget_get_direction (widget);
+  state = widget->priv->state_flags;
+  state &= GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL;
+
+  switch (direction)
+    {
+    case GTK_TEXT_DIR_LTR:
+      state |= GTK_STATE_FLAG_DIR_LTR;
+      break;
+
+    case GTK_TEXT_DIR_RTL:
+      state |= GTK_STATE_FLAG_DIR_RTL;
+      break;
+
+    case GTK_TEXT_DIR_NONE:
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
   if (widget->priv->context)
-    gtk_style_context_set_direction (widget->priv->context,
-                                     gtk_widget_get_direction (widget));
+    gtk_style_context_set_direction (widget->priv->context, direction);
+
+  gtk_widget_set_state_flags (widget, state, TRUE);
 
   g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
 }
@@ -13989,6 +14014,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
 
       priv->context = gtk_style_context_new ();
 
+      gtk_style_context_set_state (priv->context, priv->state_flags);
       gtk_style_context_set_direction (priv->context, gtk_widget_get_direction (widget));
 
       screen = gtk_widget_get_screen (widget);